package com.dt76.smallloanbackendservice.service.lhuaw.impl;

import com.dt76.smallloanbackendservice.mapper.lhuaw.AdvertisingManagementMapper;
import com.dt76.smallloanbackendservice.pojo.lhuaw.AdvertisingManagement;
import com.dt76.smallloanbackendservice.service.lhuaw.AdvertisingManagementService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdvertisingManagementServiceImpl implements AdvertisingManagementService {

    @Autowired
    private AdvertisingManagementMapper advertisingManagementMapper;
    @Override
    public List<AdvertisingManagement> qryAllAdvert() {
        System.out.println(advertisingManagementMapper.qryAllAdvert());
        return advertisingManagementMapper.qryAllAdvert();
    }

    @Override
    public Page getConditionPageAllAdvertising(int pageIndex, String advertisingName, String advertisingLocation) {
        Page page =new Page();
        page.setPageIndex(pageIndex);
        page.setTotalCount(advertisingManagementMapper.qryConditionCountAdvertising(advertisingName,advertisingLocation));
        List<AdvertisingManagement> advertisingManagementList = advertisingManagementMapper.getConditionPageAllAdvertising((page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),advertisingName,advertisingLocation);
        System.out.println(advertisingManagementList);
        page.setRows(advertisingManagementList);
        return page;
    }

    @Override
    public void delAdvertising(int advId) {
        advertisingManagementMapper.delAdvertising(advId);
    }


}
